<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{block name="title"}金夫人玛瑞莎业务系统{/block}</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="__CSS__/bootstrap.min.css">
    <link rel="stylesheet" href="__CSS__/AdminLTE.min.css">
    <link rel="stylesheet" href="__CSS__/bootstrapValidator.min.css">
    <script type="text/javascript" src="__JS__/jquery-2.2.3.min.js"></script>
    <style>
        .wrapper {
            padding: 15px;
        }

        .wrapper::after {
            clear: both;
            display: block;
            content: '';
            margin-bottom: 30px;
        }
        .panel {
            border: none;
        }

        .panel-heading {
            border-bottom: 1px dotted rgba(0, 0, 0, 0.2);
            padding: 15px;
            text-transform: uppercase;
            color: #535351;
            font-size: 16px;
            font-weight: bold;
        }


    </style>
</head>
<body >
<!--body wrapper start-->
<div class="wrapper">
    <div class="row">

        <div class="col-lg-12">
            <section class="panel">
                <header class="panel-heading">
                    编辑顾客
                </header>
                <div class="panel-body">
                    <div class=" form">
                        <form class="cmxform form-horizontal adminex-form" id="commentForm" method="post" action="{:url('editrun')}">
                            <div class="form-group ">
                                <label  class="control-label col-xs-4">用户名</label>
                                <div class="col-xs-5">
                                    <input class="form-control" name="username" type="text" value="{$info.username}" disabled/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-4">属性：</label>
                                <div class="col-xs-5">
                                    <select class="form-control" name="attr">
                                        <option value="154" {eq name="info.attr" value="154"}  selected="selected"{/eq}>员工</option>
                                        <option value="153" {eq name="info.attr" value="153"}  selected="selected"{/eq}>老顾客</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-4">状态：</label>
                                <div class="col-xs-5">
                                    <select class="form-control" name="status">
                                        <option value="0" >全部</option>
                                        <option value="1" {eq name="info.status" value="1"}  selected="selected"{/eq}>启用</option>
                                        <option value="0" {eq name="info.status" value="0"}  selected="selected"{/eq}>禁用</option>
                                    </select>
                                </div>
                            </div>
                            <!-- 类别ID -->
                            <div class="form-group">
                                <div class="col-lg-offset-2 col-xs-offset-5 col-xs-7">
                                    <input name="id" type="hidden" value="{$info.id}"/>
                                    <button class="btn btn-primary" id="submit" type="submit" >提交</button>
                                    <button class="btn btn-default" type="button" id="exit">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>

                </div>
            </section>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
<script src="__JS__/bootstrapValidator.min.js"></script>
<script src="__JS__/language/zh_CN.js"></script>
<script>
    var submits = function () {
        $.ajax({
            type: "POST",
            url:  "{:url('editrun')}",
            data: $('#commentForm').serialize(),
            beforeSend:function(){
                $(this).attr("disabled","false"); //禁止点击
            },
            success: function(info){
                if(info.code==1){
                    layer.msg(info.msg, {icon: 1});
                    setTimeout(function(){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },3000); //延迟演示
                }else{
                    layer.msg(info.msg, {icon: 5});
                    $('#submit').removeAttr("disabled"); //禁止点击
                }

            }
        });
    }
    $('#exit').click(function () {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    });
    $('#commentForm').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            username: {
                message: '用户名验证失败',
                validators: {
                    notEmpty: {
                        message: '用户名不能为空'
                    }
                }
            },
            attr: {
                validators: {
                    notEmpty: {
                        message: '属性必选'
                    }
                }
            },
            status: {
                validators: {
                    notEmpty: {
                        message: '状态必选'
                    }
                }
            }
        }
    });
    $("#commentForm").submit(function(ev){ev.preventDefault();});
    $("#submit").on("click", function(){
        var bootstrapValidator = $("#commentForm").data('bootstrapValidator');
        bootstrapValidator.validate();
        if(bootstrapValidator.isValid()){
            submits();
        }else {return;};
    });
</script>

